package mymatrix;

import result.Result;
import tasks.Task;

public class MatrixTask extends Task {

	private int size;
	private long[][] matrixA;
	private long[][] matrixB;
	private MyResult result;
	private int ini;
	private int end;
	public MatrixTask(int id, int size,long[][] matrixA, long[][] matrixB, int ini, int end) {
		super(id);
		this.size = size;
		this.matrixA = matrixA;
		this.matrixB = matrixB;
		this.ini = ini;
		this.end = end;
	}

	private long[][] mul(long matrixA[][],long matrixB[][]){
		long [][] total = new long[this.size][this.size];
		 for(int i = ini; i < this.end; i++) {
		      for(int j = 0; j < this.size; j++) {
		        for(int k = 0; k < this.size; k++){
		          
		          total[i][j] += matrixA[i][k]*matrixB[k][j];
		         
		        }
		      }  
		     }
		 return total;
		
	}
	
	@Override
	public void run() {
		result = new MyResult(mul(this.matrixA,this.matrixB), ini,end);
		
		
	}

	@Override
	public Result getResult() {
		// TODO Auto-generated method stub
		return this.result;
	}

	@Override
	public void cancel() {
		// TODO Auto-generated method stub
		
	}

}
